package com.itheima.exception;

import com.itheima.domain.Code;
import com.itheima.domain.Result;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

@RestControllerAdvice
public class ProjectExceptionAdvice  {
    @ExceptionHandler(BusinessException.class)
    public Result doBusinessException(BusinessException e){
        //控制台打印异常
        e.printStackTrace();
        return new Result(Code.BUSINESS_EXCEPTION,e.getMessage());
    }

    @ExceptionHandler({Exception.class})
    public  Result doException(Exception e){
        e.printStackTrace();
        return  new Result(Code.BUSINESS_TOLATE,"服务器维护中，稍等。。。");
    }
}
